<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./pinyin4js.js"></script>
  </head>
  <body>
    <div id="box"></div>
    <script>
      const testData = [
        {
          name: "阿张三",
          height: 175,
          age: 22,
          gender: "男",
          weight: 70,
          scores: {
            Chinese: 80,
            Math: 90,
            English: 85,
          },
          rank: 3,
        },
        {
          name: "李四",
          height: 168,
          age: 20,
          gender: "男",
          weight: 60,
          scores: {
            Chinese: 85,
            Math: 78,
            English: 92,
          },
          rank: 1,
        },
        {
          name: "不王五",
          height: 162,
          age: 19,
          gender: "女",
          weight: 50,
          scores: {
            Chinese: 90,
            Math: 88,
            English: 92,
          },
          rank: 2,
        },
        {
          name: "赵六",
          height: 170,
          age: 21,
          gender: "男",
          weight: 72,
          scores: {
            Chinese: 70,
            Math: 80,
            English: 75,
          },
          rank: 5,
        },
        {
          name: "钱七",
          height: 165,
          age: 20,
          gender: "女",
          weight: 55,
          scores: {
            Chinese: 78,
            Math: 92,
            English: 85,
          },
          rank: 4,
        },
      ];

      testData.sort((a, b) => {
        return (
          PinyinHelper.getShortPinyin(a.name[0]).charCodeAt(0) -
          PinyinHelper.getShortPinyin(b.name[0]).charCodeAt(0)
        );
      });
      console.log(testData);
      // let obj = {};
      // let index = -1;
      // testData.forEach((item) => {
      //   index = Math.floor(item.age / 10);
      //   if (!obj[index]) {
      //     obj[index] = {
      //       count: item.weight,
      //       num: 1,
      //     };
      //   } else {
      //     obj[index].count += item.weight;
      //     obj[index].num++;
      //   }
      // });
      // console.log(obj);
    </script>
  </body>
</html>
